package com.crm.service.impl.sendRoyaltyManager;

import com.crm.dao.mapper.customMapper.sendRoyaltyManager.SendRoyaltyMapper;
import com.crm.dao.mapper.sendRoyaltyManager.OrderSendRoyaltyMapper;
import com.crm.model.entity.sendRoyaltyManager.OrderSendRoyalty;
import com.crm.service.sendRoyaltyManager.SendRoyaltyDbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @Author: chaifuyou
 * @date 2021/4/7 14:25
 */
@Service
public class SendRoyaltyDbServiceImpl implements SendRoyaltyDbService {
    //自動生成的
    @Autowired
    private OrderSendRoyaltyMapper orderSendRoyaltyMapper;

    @Autowired
    private SendRoyaltyMapper sendRoyaltyMapper;

    /**
     * 录入提成
     * @param orderSendRoyalty
     */
    @Override
    public void addSendRoyalty(OrderSendRoyalty orderSendRoyalty) {
        orderSendRoyaltyMapper.insertSelective(orderSendRoyalty);
    }

    /**
     * 查询提成方法次数
     * @param productOrderId
     * @param productId
     * @return
     */
    @Override
    public Integer getSendRoyaltyNum(String productOrderId, String productId) {
        return sendRoyaltyMapper.getSendRoyaltyNum(productOrderId,productId);
    }

    /**
     * 根据订单id、产品id逻辑删除提成发放记录
     * @param orderSendRoyalty
     */
    @Override
    public void delSendRoyalty(OrderSendRoyalty orderSendRoyalty) {
        sendRoyaltyMapper.delSendRoyalty(orderSendRoyalty);
    }

    /**
     * 获取提成发放详情
     * @param orderSendRoyalty
     * @return
     */
    @Override
    public OrderSendRoyalty getSendRoyaltyInfo(OrderSendRoyalty orderSendRoyalty) {
        return sendRoyaltyMapper.getSendRoyaltyInfo(orderSendRoyalty);
    }

    /**
     * 获取最后一次发放的时间
     * @param orderId
     * @return
     */
    @Override
    public Date getMaxCreateTime(String orderId) {
        return sendRoyaltyMapper.getMaxCreateTime(orderId);
    }
}
